package com.example.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.custom.image.FeedImageView;
import com.example.taigame.R;
import com.example.utils.Utils;

public class DanhMuc_ListView_Adapter extends BaseAdapter {

	private String[] dau_muc = Utils.gameName;
	private int[] ten_icon = { R.drawable.moi_nhat, R.drawable.tai_nhieu, R.drawable.game, R.drawable.email, R.drawable.mangxahoi, R.drawable.ungdunggiaitri, R.drawable.chupxulyanh, R.drawable.quanlivideonhac, R.drawable.xemtivi, R.drawable.tuvi, R.drawable.ungdungchope, R.drawable.giaoduc, R.drawable.truyentranh, R.drawable.sachtruyen, R.drawable.tintuc, R.drawable.hinhnen, R.drawable.quanlidienthoai, R.drawable.trinhduyet, R.drawable.canhan, R.drawable.baomat, R.drawable.yte, R.drawable.dulich, R.drawable.bando, R.drawable.taichinh, R.drawable.ungdungdoanhnghiep, R.drawable.ungdungkhac };

	private Context context;

	public DanhMuc_ListView_Adapter(Context context) {
		this.context = context;
	}

	@Override
	public int getCount() {
		return dau_muc.length;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View vi = convertView;
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		vi = inflater.inflate(R.layout.danh_muc_items, null);
		TextView textView = (TextView) vi.findViewById(R.id.textView1);
		textView.setText(dau_muc[position]);
		FeedImageView image = (FeedImageView) vi.findViewById(R.id.imageView1);
		image.setImageUrl("drawable://"+ten_icon[position]);
		return vi;
	}

}
